package com.ship.contract.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ship.contract.bean.PayFundManagement;
import com.ship.contract.mapper.PayFundManagementMapper;
import com.ship.contract.service.PayFundManagementService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("PayFundManagementService")
public class PayFundManagementServiceImpl extends ContractBaseServiceImpl<PayFundManagementMapper, PayFundManagement> implements PayFundManagementService {

    /**
     * 根据合同id获取资金结算列表
     *
     * @param contractId 合同id
     * @return
     */
    @Override
    public List<PayFundManagement> getPayFundManagements(Long contractId) {
        List<PayFundManagement> payFundManagements = this.list(new LambdaQueryWrapper<PayFundManagement>()
                .eq(PayFundManagement::getAffiliatedContractId, contractId));
        return payFundManagements;
    }

    /**
     * 删除合同对应资金结算记录
     * @param orderId
     */
    @Override
    public void removePayFundManagement(Long orderId){
        PayFundManagement fundManagement = this.getOne(new LambdaQueryWrapper<PayFundManagement>().eq(PayFundManagement::getOrderId,orderId));
        if(null != fundManagement){
            this.removeById(fundManagement);
        }
    }

}
